home *** CD-ROM | disk | FTP | other *** search
/ LG Super CD / LG Super CD.iso / bitpim / bitpim-0.62-setup.exe / {app} / bitpim.exe / dummy_thread.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2003-11-06  |  3.2 KB  |  102 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.3)
  3.  
  4. __author__ = 'Brett Cannon'
  5. __email__ = 'brett@python.org'
  6. __all__ = [
  7.     'error',
  8.     'start_new_thread',
  9.     'exit',
  10.     'get_ident',
  11.     'allocate_lock',
  12.     'interrupt_main',
  13.     'LockType']
  14. import traceback as _traceback
  15.  
  16. class error(Exception):
  17.     
  18.     def __init__(self, *args):
  19.         self.args = args
  20.  
  21.  
  22.  
  23. def start_new_thread(function, args, kwargs = { }):
  24.     global _main, _main, _interrupt
  25.     if type(args) != type(tuple()):
  26.         raise TypeError('2nd arg must be a tuple')
  27.     
  28.     if type(kwargs) != type(dict()):
  29.         raise TypeError('3rd arg must be a dict')
  30.     
  31.     _main = False
  32.     
  33.     try:
  34.         function(*args, **kwargs)
  35.     except SystemExit:
  36.         pass
  37.     except:
  38.         _traceback.print_exc()
  39.  
  40.     _main = True
  41.     if _interrupt:
  42.         _interrupt = False
  43.         raise KeyboardInterrupt
  44.     
  45.  
  46.  
  47. def exit():
  48.     raise SystemExit
  49.  
  50.  
  51. def get_ident():
  52.     return -1
  53.  
  54.  
  55. def allocate_lock():
  56.     return LockType()
  57.  
  58.  
  59. class LockType(object):
  60.     
  61.     def __init__(self):
  62.         self.locked_status = False
  63.  
  64.     
  65.     def acquire(self, waitflag = None):
  66.         if waitflag is None:
  67.             self.locked_status = True
  68.             return None
  69.         elif not waitflag:
  70.             if not (self.locked_status):
  71.                 self.locked_status = True
  72.                 return True
  73.             else:
  74.                 return False
  75.         else:
  76.             self.locked_status = True
  77.             return True
  78.  
  79.     
  80.     def release(self):
  81.         if not (self.locked_status):
  82.             raise error
  83.         
  84.         self.locked_status = False
  85.         return True
  86.  
  87.     
  88.     def locked(self):
  89.         return self.locked_status
  90.  
  91.  
  92. _interrupt = False
  93. _main = True
  94.  
  95. def interrupt_main():
  96.     global _interrupt
  97.     if _main:
  98.         raise KeyboardInterrupt
  99.     else:
  100.         _interrupt = True
  101.  
  102.